#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt

from inary.actionsapi import get
from inary.actionsapi import autotools
from inary.actionsapi import inarytools
from inary.actionsapi import shelltools

def setup():
    shelltools.system("""sed -i '/pragma weak pthread_create/d' tests/glthread/thread.h""")
    libdir="lib"
    if get.buildTYPE() == "emul32":
        shelltools.export("CC","gcc -m32")
        shelltools.export("CXX","g++ -m32")
        libdir+="32"
        shelltools.reset_env()
    autotools.configure("""--bindir=/bin \
                           --libdir=/{}""".format(libdir))

def build():
    autotools.make()

#def check():
#    autotools.make("check")

def install():
    autotools.make("DESTDIR=%s install" % get.installDIR())

    if get.buildTYPE() == "emul32":
        inarytools.dosym("libunistring.so.2.1.0", "/lib32/libunistring.so.0")
        return
    inarytools.dosym("libunistring.so.2.1.0", "/lib/libunistring.so.0")
    inarytools.dodoc("AUTHORS", "BUGS", "ChangeLog", "COPYING", "COPYING.LIB", "HACKING", "NEWS", "README",  "THANKS")
